<style>
  .ivu-input[disabled], fieldset[disabled] .ivu-input {
    background-color: white;
    opacity: 1;
    cursor: not-allowed;
    color: #515A6E;
  }
  .ivu-select-disabled .ivu-select-selection {
    background-color: white;
    opacity: 1;
    cursor: not-allowed;
    color: #515A6E;
  }
  .ivu-select-input[disabled] {
    cursor: not-allowed;
    color: #515A6E;
    -webkit-text-fill-color: #515A6E;
}
</style>
<template>
    <div class="form-block-inner">
      <Form :model="formInfo" label-position="top" ref="addBaseForm">

        <div class="title-style">查询条件</div>
        <Row :gutter="16">
          <Col span="6">
            <FormItem label="  登录账号" >
              <Input type="text" v-model="formInfo.login_name" placeholder="请输入登录账号"/>
            </FormItem>
          </Col>
          <Col span="3">
            <Button type="primary" class="save-btn mr20" long @click="getUserInfoByLoginNameSub ()">查 询</Button>
          </Col>
        </Row>
        <div class="title-style">基本信息</div>
        <Row :gutter="16">
          <Col span="6">
            <FormItem label="  机构名称" >
              <Input type="text" v-model="formInfo.company_name"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  机构ID" >
              <Input type="text" v-model="formInfo.company_id"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  officeID" >
              <Input type="text" v-model="formInfo.office_id"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  登录账号" >
              <Input type="text" v-model="formInfo.login_name"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  名称" >
              <Input type="text" v-model="formInfo.name"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  电话" >
              <Input type="text" v-model="formInfo.phone"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  手机号" >
              <Input type="text" v-model="formInfo.mobile"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  是否可以登录" >
              <Input type="text" v-model="formInfo.login_flag"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  登录失败次数" >
              <Input type="text" v-model="formInfo.login_fail"  disabled />
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="  当前密码(密文)" >
              <Input type="text" v-model="formInfo.password"  disabled />
            </FormItem>
          </Col>
          <!-- </Row>
           <Row :gutter="16"> -->
          <Col span="3" offset="8">
           <Button type="warning" class="save-btn mr20" long @click="updateResetAccountSub ()">重 置</Button>
          </Col>
        </Row>
      </Form>
    </div>
</template>
<script>
import { getUserInfoByLoginName, updateResetAccount } from '@/api/common'

export default {
  name: 'index',
  data () {
    return {
      formInfo: {
        login_name: ''
      }
    }
  },
  methods: {
    getUserInfoByLoginNameSub () {
      var param = {
        loginName: this.formInfo.login_name
      }
      getUserInfoByLoginName(param).then(res => {
        console.log(res.data.data.login_name)
        if (res.data.errcode === 0) {
          var retdata = {
            id: res.data.data.id,
            company_name: res.data.data.company_name,
            company_id: res.data.data.company_id,
            office_id: res.data.data.office_id,
            login_name: res.data.data.login_name,
            name: res.data.data.name,
            phone: res.data.data.phone,
            mobile: res.data.data.mobile,
            login_flag: res.data.data.login_flag,
            login_fail: res.data.data.login_fail,
            password: res.data.data.password
          }
          this.formInfo = retdata
          // this.formInfo.id = res.data.data.id
          // this.formInfo.company_name = res.data.company_name
          // this.formInfo.company_id = res.data.data.company_id
          // this.formInfo.office_id = res.data.data.office_id
          // this.formInfo.login_name = res.data.data.login_name
          // this.formInfo.name = res.data.data.name
          // this.formInfo.phone = res.data.data.phone
          // this.formInfo.mobile = res.data.data.mobile
          // this.formInfo.login_flag = res.data.data.login_flag
          // this.formInfo.login_fail = res.data.data.login_fail
          // this.formInfo.password = res.data.data.password
        } else {
          this.$Notice.error({ title: res.data.errmsg })
        }
        console.log(this.formInfo)
      })
    },
    updateResetAccountSub () {
      console.log(this.formInfo.id)
      if (!this.formInfo.id) {
        this.$Notice.error({ title: '重置失败，请输入账号。' })
      }
      var param = {
        id: this.formInfo.id
      }
      updateResetAccount(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '重置成功' })
          var formInfo = {
            login_name: ''
          }
          this.formInfo = formInfo
        } else {
        }
        this.saving = false
      })
    }
  }
}
</script>

<style scoped>
  .title-style {
    padding: 8px 12px;
    background-color: #ecf8ff;
    border-radius: 4px;
    border-left: 5px solid #50bfff;
    margin: 15px 0;
    font-size: 16px;
    width: 100%;
  }
  .table-mr5 {
    margin-right: 5px;
  }
  .add-btn {
    float: right;
    font-size: 15px;
  }
  .save-btn {
    margin: 20px;
    floaat: right;
  }
  .mr20 {
    margin-right: 20px;
  }
  .bench_search {
    margin-bottom: 10px;
  }
  .help-tip {
    cursor:pointer;
    color: #5cadff;
  }
  .red-star {
    font-family: SimSun;
    color: #f00;
    margin-right: 4px;
  }
</style>
